package com.bltec.emergency.mapper;


import com.bltec.emergency.model.ResStatistics;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
@Mapper
public interface ResStatisticsMapper {
    //插入一条ResStatistics记录
    @Insert("insert into res_statistics (area,type,department_id,time,total_realized,total_type,total_number,account_for," +
            "create_by,create_time,enable) " +
            "values(#{area},#{type},#{departmentId},#{time},#{totalRealized},#{totalType},#{totalNumber},#{accountFor}," +
            "#{createBy},#{createTime},#{enable})")
    boolean insert(ResStatistics resStatistics);

    //通过id设置一条记录为不可用
    @Update("update res_statistics set enable=0 where id=#{id}")
    boolean setDisableById(Long id);

    //通过id更新一条记录
    @Update("update res_statistics set area=#{area},type=#{type},department_id=#{departmentId}," +
            "time=#{time},total_realized=#{totalRealized},total_type=#{totalType},total_number=#{totalNumber},account_for=#{accountFor}," +
            "update_by=#{updateBy},update_time=#{updateTime} where id=#{id}")
    boolean updateResStatisticsById(ResStatistics resStatistics);

    //查找符合id字段的记录
    @Select("select id,area,type,department_id,time,total_realized,total_type,total_number,account_for," +
            "create_by,create_time,update_by,update_time,enable" +
            " from res_statistics where id =#{id} and enable=1")
    ResStatistics getResStatisticsById(Long id);

    //查找所有记录
    @Select("select id,area,type,department_id,time,total_realized,total_type,total_number,account_for," +
            "create_by,create_time,update_by,update_time,enable" +
            " from res_statistics where enable=1")
    List<ResStatistics> selectAll();
}